#include <iostream>
#include "Graph.h"
using namespace std;

void CreateGraph(Graph * &graph) {
	/*  G ----------------------------------- H DFS: 	    				
	 *  |                                     |      A        G
	 *  |   A --------------------------- E   |      |        |
	 *  |   |\                           /|	  |      C        H
	 *  |   | \                         / |	  |      | \      |
	 *  |   |  C --------------------- F  |	  |      D  F     I
	 *  |   | /                         \ |   |         |     |
	 *  |   |/                           \|	  |         B     J
	 *  |   D                             B	  |         |
	 *  |                                     |         E
	 *  J ----------------------------------- I
	 */
	graph = new Graph;
	LinkNode *temp, *curr;
	for (char ch = 'A'; ch <= 'J'; ++ch) {
		temp = new LinkNode;
		temp->node.push_back(ch);
		temp->prev = NULL;
		temp->next = NULL;
		graph->graphlink.push_back(make_pair(temp, 0));
	}
	
	//For Vertex A
	curr = graph->graphlink[0].first;
	temp = new LinkNode;
	temp->node = "C";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;
	curr = temp;
	temp = new LinkNode;
	temp->node = "D";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;
	curr = temp;
	temp = new LinkNode;
	temp->node = "E";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;
	
	//For Vertex B
	curr = graph->graphlink[1].first;
	temp = new LinkNode;
	temp->node = "E";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;
	curr = temp;
	temp = new LinkNode;
	temp->node = "F";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;
	
	//For Vertex C
	curr = graph->graphlink[2].first;
	temp = new LinkNode;
	temp->node = "A";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;
	curr = temp;
	temp = new LinkNode;
	temp->node = "D";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;
	curr = temp;
	temp = new LinkNode;
	temp->node = "F";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;

	//For Vertex D
	curr = graph->graphlink[3].first;
	temp = new LinkNode;
	temp->node = "A";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;
	curr = temp;
	temp = new LinkNode;
	temp->node = "C";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;

	//For Vertex E
	curr = graph->graphlink[4].first;
	temp = new LinkNode;
	temp->node = "A";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;
	curr = temp;
	temp = new LinkNode;
	temp->node = "B";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;
	curr = temp;
	temp = new LinkNode;
	temp->node = "F";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;

	//For Vertex F
	curr = graph->graphlink[5].first;
	temp = new LinkNode;
	temp->node = "B";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;
	curr = temp;
	temp = new LinkNode;
	temp->node = "C";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;
	curr = temp;
	temp = new LinkNode;
	temp->node = "E";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;

	//For Vertex G
	curr = graph->graphlink[6].first;
	temp = new LinkNode;
	temp->node = "H";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;
	curr = temp;
	temp = new LinkNode;
	temp->node = "J";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;

	//For Vertex H
	curr = graph->graphlink[7].first;
	temp = new LinkNode;
	temp->node = "G";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;
	curr = temp;
	temp = new LinkNode;
	temp->node = "I";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;

	//For Vertex I
	curr = graph->graphlink[8].first;
	temp = new LinkNode;
	temp->node = "H";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;
	curr = temp;
	temp = new LinkNode;
	temp->node = "J";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;

	//For Vertex J
	curr = graph->graphlink[9].first;
	temp = new LinkNode;
	temp->node = "G";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;
	curr = temp;
	temp = new LinkNode;
	temp->node = "I";
	temp->prev = NULL;
	temp->next = NULL;
	curr->next = temp;
}

void ClearGraphStatus(Graph *graph) {
	vector<pair<LinkNode *, int> >::iterator it;
	it = graph->graphlink.begin();
	for (; it != graph->graphlink.end(); ++it) {
		it->second = 0;
	}
}
